/*
 * @Author: zhangfeng
 * @Date: 2023-12-25 14:55:22
 * @LastEditTime: 2023-12-29 14:55:22
 * @LastEditors: zhangfeng
 * @Description:
 * @FilePath: \nodeapi\src\model\role-menus.model.js
 * © 2023 张峰，All rights reserved.
 */
const { DataTypes } = require("sequelize");
const seq = require("../db/seq");

// 创建角色菜单模型

const RolePremission = seq.define(
  "zd_role_premission",
  {
    roleId: {
      type: DataTypes.INTEGER,
      allowNull: false,
      primaryKey: true,
      comments: "角色id",
      references: {
        model: "zd_roles",
        key: "id",
      },
    },
    premissionId: {
      type: DataTypes.INTEGER,
      allowNull: false,
      primaryKey: true,
      comments: "菜单(权限)id",
      references: {
        model: "zd_menus",
        key: "id",
      },
    },
  },
  {
    tableName: "zd_role_premissions",
    // timestamps: false,
    // paranoid: true,
  }
);
// RolePermission.removeAttribute("id");

// RolePermission.sync({ force: true });

// process.on("uncaughtException", (err) => {
//   console.error("Uncaught Exception:", err.stack);
//   process.exit(1); // 可选地终止进程
// });
module.exports = RolePremission;
